<template>
    <div>
        <img src="http://jysh.oss-cn-qingdao.aliyuncs.com/Eric/WechatIMG3086.png" class="hd-img-responsive">
        <van-row>
            <van-col span="24">
                <van-cell-group class="input-base" :border="false">
                    <van-field disabled v-model="this.name" label="专家姓名" :placeholder="this.name"/>
<!--                    <van-field disabled v-model="this.tel" label="专家电话" :placeholder="this.tel" />-->
                    <van-field v-model="lmname" label="真实姓名" placeholder="姓名" />
                    <van-field v-model="lmtelephone"  label="联系电话" placeholder="电话"   @blur="yanzhengtel" />
                    <van-field v-model="lmmessage" label="留言" type="textarea" placeholder="请输入留言" rows="1" autosize/>
                </van-cell-group>
            </van-col>
            <!--            <van-col span="24" class="up-loader">-->
            <!--                <van-row>-->
            <!--                    <van-col span="8">-->
            <!--                        <div class="loader-title">上传补充资料</div>-->
            <!--                    </van-col>-->
            <!--                    <van-col span="12">-->
            <!--                        <div class="up-icorn">-->
            <!--                            <uploader-img :num="1" @result="resultAction"></uploader-img>-->
            <!--                        </div>-->
            <!--                    </van-col>-->
            <!--                </van-row>-->
            <!--            </van-col>-->
        </van-row>
        <van-row>
            <van-col span="24" >
                <van-button plain hairline type="primary"  class="down-button " @click="btnmsg">确定留言</van-button>
            </van-col>
        </van-row>
    </div>
</template>

<script>
import { epidemicleavingmessage } from '@/api/mine'
import { getOpenidMsg } from '@/api/yi-qing-fang-kong.js'
import { Dialog } from 'vant'
export default {
  name: 'index',
  data () {
    return {
      lmname: '',
      msg: '',
      lmtelephone: '',
      lmmessage: '',
      fileone1: [],
      img: '',
      experts_id: '',
      name: '',
      tel: '',
      list: {}
    }
  },
  methods: {
    init () {
      getOpenidMsg().then(ret => {
        if (ret.data.errcode === 0) {
          console.log('获取注册过的人员信息', ret.data)
          this.lmname = ret.data.data.result.name
          this.lmtelephone = ret.data.data.result.tel
        } else {
          this.failNotice(ret.data.errmsg)
        }
      })
      this.experts_id = this.$route.params.id
      this.name = this.$route.params.name
      this.tel = this.$route.params.tel
      console.log('接到的参数', this.experts_id + ',' + this.name)
    },
    yanzhengtel () {
      var reg = /^((13[0-9])|(17[0-1,6-8])|(15[^4,\\D])|(18[0-9]))\d{8}$/
      if (reg.test(this.lmtelephone) === false) {
        Dialog.alert({
          message: '请输入正确的手机号'
        }).then(() => {
          this.lmtelephone = ''
        })
      }
    },
    btnmsg () {
      let data = {
        leaving_message_name: this.lmname,
        leaving_message_telephone: this.lmtelephone,
        experts_leaving_message: this.lmmessage,
        leaving_message_img: '',
        experts_id: this.experts_id
      }
      epidemicleavingmessage(data).then(ret => {
        console.log(data, '保存的参数')
        if (ret.data.errcode === 0) {
          this.$dialog.alert({
            message: '留言成功'
          }).then(() => {
            this.$router.push({
              path: '/remote-inquiry-user-msg',
              params: {
                id: data.experts_id
              }
            })
          })
        }
      })
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style scoped>
    .in-title{
        margin-top: 15px;
        margin-left: 20px;
        height: 30px;
        border-left: 3px solid #E51C23;
    }
    .font-title{
        margin-top: 1.125rem;
        font-weight: 500;
    }
    .input-base{
        margin-top: 5px;
    }

    .up-loader{
        font-size:13px;
    }
    .loader-title{
        font-weight: 600;
        margin-top: 20px;
        margin-left: 10px
    }
    .up-icorn{
        margin-top: 0.625rem;
    }
    .down-button{
        margin-top: 20px;
        margin-left: 5px;
        height: 40px;
        width: 97%;
        line-height: 30px;
        border: solid 1px #9CC94E;
        background-color: #9cc94e;
        color: white;
    }
</style>
